package demo;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;

import java.util.ArrayList;
import java.util.List;

public class DemoListener extends AnalysisEventListener<Product> {

    private List<Product> products = new ArrayList<>();

    @Override
    public void invoke(Product product, AnalysisContext analysisContext) {
        //每次解析一个对象时候调用这个方法一次
        System.out.println("解析了一个Product对象："+product);
        products.add(product);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        System.out.println("全部解析完成");
    }

    public List<Product> getProducts() {
        return products;
    }
}
